//*************************************************************************//
//*           _____   ____________            ______               __     *//
//*          / /__ \ / ____/ ____/           / ____/___  _________/ /     *//
//*     __  / /__/ // __/ / __/    ______   / /_  / __ \/ ___/ __  /      *//
//*    / /_/ // __// /___/ /___   /_____/  / __/ / /_/ / /  / /_/ /       *//
//*    \____//____/_____/_____/           /_/    \____/_/   \__,_/        *//
//*                                                                       *//
//*     Copyright (c) 2006 Ford Argentina. All Rights Reserved.           *//
//*                                                                       *//
//*************************************************************************//

package ar.com.ford.it.webengine.persistence;

import com.ford.it.logging.ILogger;
import com.ford.it.logging.Level;
import com.ford.it.logging.LogFactory;

public class PersistenceManagerProviderFactory {
	private static final String CLASS_NAME = PersistenceManagerProviderFactory.class.getName();
	private static final ILogger log = LogFactory.getInstance().getLogger(CLASS_NAME);
	
	private static IPersistenceManagerProvider persistenceManagerProvider;
	
	public static void init(String className) {
		String METHOD_NAME = "init";
		log.entering(CLASS_NAME, METHOD_NAME, className);
		
		if (persistenceManagerProvider == null) {
			try {
				persistenceManagerProvider = (IPersistenceManagerProvider)Class.forName(className).newInstance();
			}
			catch (Exception e) {
	            log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME, "cannot create ISecurityProvider", className);
	            log.logp(Level.SEVERE, CLASS_NAME, METHOD_NAME, "Exception", e);
	            persistenceManagerProvider = null;
			}
		}
		log.exiting(CLASS_NAME, METHOD_NAME);
	}
	
	public static IPersistenceManagerProvider getPersistenceProvider() {
		return persistenceManagerProvider;
	}	
	
	
}
